bitkeeper revision 1.807 (4058872eScocwS_6SkwoZWFMzDk9Nw)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Wed, 17 Mar 2004 17:13:18 +0000 (17:13 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Wed, 17 Mar 2004 17:13:18 +0000 (17:13 +0000)
utils.c, control_if.h:
  Move shared controller-interface definitions out of the xenolinux tree.
console_client.py:
  Fix console client.
control_if.h:
  bk cp xenolinux-2.4.25-sparse/include/asm-xeno/control_if.h tools/xend/lib/control_if.h
  Rewritten the Xen control daemon in Python, with C extensions for the low-level bits. All our Python libraries now throw exceptions on error rather than returning error codes --- this will require our higher-level scripts to be updated at some point.
  new file

.rootkeys
tools/xenctl/lib/console_client.py
tools/xend/lib/control_if.h [new file with mode: 0644]
tools/xend/lib/utils.c
tools/xend/setup.py

index 5aed5695a82b7b5c29102b585a6415b2e4df2649..b000ea2a906f591b717231e65125c044b2e3c66e 100644 (file)
--- a/.rootkeys
+++ b/.rootkeys
@@ -96,6 +96,7 @@
 40431ac64Hj4ixUnKmlugZKhXPFE_Q tools/xend/Makefile
 4055ad95Se-FqttgxollqOAAHB94zA tools/xend/lib/__init__.py
 4055ad97wMLUj0BZT0e_T0EwQN0Bvw tools/xend/lib/console.py
+4048c0ddsF0WrU7HUzTvg1MJoCIfWg tools/xend/lib/control_if.h
 4054a301VEag2GwrBrFBna5U1BGlLA tools/xend/lib/main.py
 4055ad9ah9IuC3sJT2c_gYIFY5Tw_g tools/xend/lib/manager.py
 40431ac8wrUEj-XM7B8smFtx_HA7lQ tools/xend/lib/utils.c
index d4dfb78e66fc4ad2734c75a72bc681d3333bc934..df15d6f1d344d44c06d30f3ec7f5cd56c54ac6d4 100644 (file)
@@ -5,7 +5,17 @@
 # Copyright (c) 2004, K A Fraser
 ##############################################
 
-import errno, os, signal, socket, struct, sys, termios
+import errno, os, signal, socket, struct, sys
+
+from termios import *
+# Indexes into termios.tcgetattr() list.
+IFLAG  = 0
+OFLAG  = 1
+CFLAG  = 2
+LFLAG  = 3
+ISPEED = 4
+OSPEED = 5
+CC     = 6
 
 def __child_death(signum, frame):
     global stop
@@ -14,7 +24,6 @@ def __child_death(signum, frame):
 def __recv_from_sock(sock):
     global stop
     stop = False
-    print "************ REMOTE CONSOLE: CTRL-] TO QUIT ********"
     while not stop:
         try:
             data = sock.recv(1)
@@ -22,8 +31,6 @@ def __recv_from_sock(sock):
         except socket.error, error:
             if error[0] != errno.EINTR:
                 raise
-    print
-    print "************ REMOTE CONSOLE EXITED *****************"
     os.wait()
 
 def __send_to_sock(sock):
@@ -41,21 +48,28 @@ def connect(host,port):
                     struct.pack('ii', 0, 0))
     sock.connect((host,port))
 
-    oattrs = termios.tcgetattr(0)
-    nattrs = termios.tcgetattr(0)
-    nattrs[3] = nattrs[3] & ~(termios.ECHO | termios.ICANON)
-    nattrs[6][termios.VMIN] = 1
-    nattrs[6][termios.VTIME] = 0
-    termios.tcsetattr(0, termios.TCSAFLUSH, nattrs)
+    oattrs = tcgetattr(0)
+    nattrs = tcgetattr(0)
+    nattrs[IFLAG] = nattrs[IFLAG] & ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON)
+    nattrs[OFLAG] = nattrs[OFLAG] & ~(OPOST)
+    nattrs[CFLAG] = nattrs[CFLAG] & ~(CSIZE | PARENB)
+    nattrs[CFLAG] = nattrs[CFLAG] | CS8
+    nattrs[LFLAG] = nattrs[LFLAG] & ~(ECHO | ICANON | IEXTEN | ISIG)
+    nattrs[CC][VMIN] = 1
+    nattrs[CC][VTIME] = 0
 
-    try:
-        if os.fork():
-            signal.signal(signal.SIGCHLD, __child_death)
+    if os.fork():
+        signal.signal(signal.SIGCHLD, __child_death)
+        print "************ REMOTE CONSOLE: CTRL-] TO QUIT ********"
+        tcsetattr(0, TCSAFLUSH, nattrs)
+        try:
             __recv_from_sock(sock)
-        else:
-            __send_to_sock(sock)
-    finally:
-        termios.tcsetattr(0, termios.TCSAFLUSH, oattrs)
+        finally:
+            tcsetattr(0, TCSAFLUSH, oattrs)
+            print
+            print "************ REMOTE CONSOLE EXITED *****************"
+    else:
+        __send_to_sock(sock)
 
 if __name__ == '__main__':
     connect(str(sys.argv[1]),int(sys.argv[2]))
diff --git a/tools/xend/lib/control_if.h b/tools/xend/lib/control_if.h
new file mode 100644 (file)
index 0000000..299feeb
--- /dev/null
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * control_if.h
+ * 
+ * Interface to server controller (e.g., 'xend'). This header file defines the 
+ * interface that is shared with guest OSes.
+ * 
+ * Copyright (c) 2004, K A Fraser
+ */
+
+#ifndef __CONTROL_IF_H__
+#define __CONTROL_IF_H__
+
+typedef struct {
+    u8 type;     /* echoed in response */
+    u8 subtype;  /* echoed in response */
+    u8 id;       /* echoed in response */
+    u8 length;   /* number of bytes in 'msg' */
+    unsigned char msg[60]; /* type-specific message data */
+} control_msg_t;
+
+#define CONTROL_RING_SIZE 8
+typedef unsigned int CONTROL_RING_IDX;
+#define MASK_CONTROL_IDX(_i) ((_i)&(CONTROL_RING_SIZE-1))
+
+typedef struct {
+    control_msg_t tx_ring[CONTROL_RING_SIZE]; /* guest-OS -> controller */
+    control_msg_t rx_ring[CONTROL_RING_SIZE]; /* controller -> guest-OS */
+    CONTROL_RING_IDX tx_req_prod, tx_resp_prod;
+    CONTROL_RING_IDX rx_req_prod, rx_resp_prod;
+} control_if_t;
+
+#define CMSG_CONSOLE      0
+#define CMSG_CONSOLE_DATA 0
+
+#endif /* __CONTROL_IF_H__ */
index c5954043d61babf229a8ca21ae37f10d9d394447..24064b6a45d0e1278cd206be511882285f6e2936 100644 (file)
@@ -21,7 +21,7 @@
 #include <errno.h>
 #include <signal.h>
 #include <xc.h>
-#include <asm-xeno/control_if.h>
+#include "control_if.h"
 
 /* Needed for Python versions earlier than 2.3. */
 #ifndef PyMODINIT_FUNC
index 3dc84d61fa6e30abeccb9013ca63f984afe4b82d..6a2c9225d7c185c9f430c34a666c1cdc0260ed24 100644 (file)
@@ -2,8 +2,7 @@
 from distutils.core import setup, Extension
 
 utils = Extension("utils",
-                  include_dirs         = ["../xc/lib",
-                                          "../../xenolinux-sparse/include"],
+                  include_dirs         = ["../xc/lib"],
                   library_dirs         = ["../xc/lib"],
                   libraries            = ["xc"],
                   sources              = ["lib/utils.c"])